package com.example.spinning.service;

import com.example.spinning.bean.EndQuality;
import com.example.spinning.bean.SemiQuality;
import com.example.spinning.mapper.EndQualityMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;


@Service
@Transactional
public class EndQualityService {
    @Autowired
    EndQualityMapper endQualityMapper;


    //增加操作
    public int addNewEndQuality(EndQuality endQuality) {
        return endQualityMapper.addNewEndQuality(endQuality);
    }

    //删除操作
    public boolean deleteEndQualityById(Long[] ids) {
        int result = endQualityMapper.deleteEndQualityById(ids);
        return result == ids.length;
    }

    //查询并分页
    public PageInfo<EndQuality> findPage(Integer page, Integer size,String batch_no, String name, Date date) {

        EndQuality endQuality = new EndQuality();
        endQuality.setBatch_no(batch_no);
        endQuality.setName(name);
        endQuality.setDate(date);

        PageHelper.startPage(page,size);
        List<EndQuality> list = endQualityMapper.select(endQuality);
        PageInfo<EndQuality> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
    //动态修改
    public int updateCategoryById(EndQuality endQuality){
        int result = endQualityMapper.updateByPrimaryKeySelective(endQuality);
        return result;
    }


}

